﻿/*  Copyright 2012 PerceiveIT Limited
 *  This file is part of the Scryber library.
 *
 *  You can redistribute Scryber and/or modify 
 *  it under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 * 
 *  Scryber is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 * 
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with Scryber source code in the COPYING.txt file.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */

using System;
using System.Collections.Generic;
using System.Text;

namespace Scryber.Styles.Old
{

    /// <summary>
    /// A PDFStyleValue is a single immutable value used in a style.
    /// It has a string representation and a object value. Most will not deal 
    /// directly with the PDFStyleValue itself, but with teh accessor properties on 
    /// Style Items that conatin a collection of style values
    /// </summary>
    public class PDFStyleValue
    {
        private string _txt;


        /// <summary>
        /// Gets the string representation of this instance
        /// </summary>
        public string Text
        {
            get { return _txt; }
        }

        private object _val;

        /// <summary>
        /// Gets the actual value in this tyle value - could be null if this value has not been parsed.
        /// </summary>
        public object Value
        {
            get { return _val; }
        }

        private bool _isparsed;

        /// <summary>
        /// Returns true if this style value has a parsed value (otherwise false).
        /// </summary>
        public bool HasParsedValue
        {
            get { return this._isparsed; }
        }

        /// <summary>
        /// Sets the actual parsed value in this instance (also sets the HasParsed to true)
        /// </summary>
        /// <param name="value"></param>
        public void SetParsedValue(object value)
        {
            this._isparsed = true;
            this._val = value;
        }

        /// <summary>
        /// Creates a new PDFStyleValue with the specified string representation, but a null value.
        /// </summary>
        /// <param name="text"></param>
        public PDFStyleValue(string text)
        {
            this._txt = text;
            this._val = null;
            this._isparsed = false;
        }

        /// <summary>
        /// Create a new PDFStyleValue with the specified string representation and specified value.
        /// Also set has parsed value to true.
        /// </summary>
        /// <param name="text"></param>
        /// <param name="value"></param>
        public PDFStyleValue(string text, object value)
        {
            this._txt = text;
            this._val = value;
            this._isparsed = true;
        }



    }
}
